package com.py.credit.service.impl;

import com.py.credit.dao.LhjcNetworkMapDao;
import com.py.credit.service.LhjcNetworkMapService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 诉说奖惩相关图表
 */
@Service
public class LhjcNetworkMapServiceImpl implements LhjcNetworkMapService {

    @Autowired
    private LhjcNetworkMapDao lhjcNetworkMapDao;

    @Override
    public List<LinkedHashMap> selectFrHeimdIndustry(String date) {
        return lhjcNetworkMapDao.selectFrHeimdIndustry(date);
    }

    @Override
    public List<LinkedHashMap> selectFrHongmdIndustry(String date) {
        return lhjcNetworkMapDao.selectFrHongmdIndustry(date);
    }

    @Override
    public List<LinkedHashMap> selectZrrHeimdSex() {
        return lhjcNetworkMapDao.selectZrrHeimdSex();
    }

    @Override
    public List<LinkedHashMap> selectZrrHongmdSex() {
        return lhjcNetworkMapDao.selectZrrHongmdSex();
    }

    @Override
    public List<LinkedHashMap> selectZrrHeimdAge(String sexType) {
        return lhjcNetworkMapDao.selectZrrHeimdAge(sexType);
    }

    @Override
    public List<LinkedHashMap> selectZrrHongmdAge(String sexType) {
        return lhjcNetworkMapDao.selectZrrHongmdAge(sexType);
    }

    @Override
    public List<LinkedHashMap> selectOverallSituation(String jclb) {
        List<LinkedHashMap> data = new ArrayList<LinkedHashMap>();
        List<LinkedHashMap> areaList = lhjcNetworkMapDao.selectAreaList();

        if (jclb.equals("C")) {
            for (LinkedHashMap area : areaList
                    ) {
                LinkedHashMap map = new LinkedHashMap();
                map.put("areaCode", area.get("areaCode"));
                map.put("areaName", area.get("areaName"));
                map.put("count", lhjcNetworkMapDao.selectHeimdOverallSituationChart((Long) area.get("areaId")));
                data.add(map);
            }
        } else {
            for (LinkedHashMap area : areaList
                    ) {
                LinkedHashMap map = new LinkedHashMap();
                map.put("areaCode", area.get("areaCode"));
                map.put("areaName", area.get("areaName"));
                map.put("count", lhjcNetworkMapDao.selectHongmdOverallSituationChart((Long) area.get("areaId")));
                data.add(map);
            }
        }

        return data;
    }
    
    public List<Map> getXycn(String ztmc,String bm,String type){
    	return lhjcNetworkMapDao.getXycn(ztmc,bm,type);
    }
    
    public List<Map> getXzcf(String ztmc,String bm,String type){
    	if("C".equals(type)){
    		return lhjcNetworkMapDao.getXzcf(ztmc);
    	}else if("P".equals(type)){
    		return lhjcNetworkMapDao.getXzcfzrr(ztmc,bm);
    	}
    	return null;
    } 
    public List<Map> getHmd(String ztmc,String bm,String type){
    	if("C".equals(type)){
    		return lhjcNetworkMapDao.getHmd(ztmc);
    	}else if("P".equals(type)){
    		return lhjcNetworkMapDao.getHmdzrr(ztmc,bm);
    	}
    	return null;
    }
    
    public String getTybmByqymc(String ztName,String ztBm, String kid){
    	String tybm= "";
    	if("100000".equals(kid)){
    		tybm = lhjcNetworkMapDao.getTybmByqymcFr(ztName);
    	}
    	if("100001".equals(kid)){
    		tybm = lhjcNetworkMapDao.getTybmByqymcZrr(ztName,ztBm);
    	}
    	if("100002".equals(kid)){
    		tybm = lhjcNetworkMapDao.getTybmByqymcFfr(ztName,ztBm);
    	}
    	return tybm;
    }
    
}
